package com.ls.fw.config.zookeeper.listener;
import org.springframework.context.ApplicationListener;
import org.springframework.core.Ordered;

import com.ls.fw.config.zookeeper.enums.EventType;
import com.ls.fw.config.zookeeper.event.NodeRefreshEventForServer;  
  
public abstract class ServerListener implements ApplicationListener<NodeRefreshEventForServer>, Ordered  {  
  
    @Override  
    public void onApplicationEvent(final NodeRefreshEventForServer event) {  
    	EventType type = event.getEventType();
    	if(type != null){
    		switch (type) {
				case ADDED:
					added(event);
					break;
				case CONNECTION_LOST:
					break;
				case CONNECTION_RECONNECTED:
					break;
				case CONNECTION_SUSPENDED:
					break;
				case INITIALIZED:
					break;
				case REMOVED:
					deleted(event);
					break;
				case UPDATED:
					updated(event);
					break;
				default:
					break;
			}
    	}
    }  
    
    public abstract void updated(final NodeRefreshEventForServer event);
    
    public abstract void deleted(final NodeRefreshEventForServer event);
    
    public abstract void added(final NodeRefreshEventForServer event);
    
    @Override  
    public int getOrder() {  
        return 1;  
    }  
}  